<template>
	<view class="content">
		<!-- <u-navbar leftIcon="arrow-leftward" title="找合同-婚姻家庭" leftIconColor="#333" placeholder autoBack bgColor="#fff" :titleStyle="titleStyle"></u-navbar> -->
		<navbar :title='title'>
		</navbar>
		<u-sticky offset-top="0">
			<view class="souview">
				<view class="souitem">
					<image class="icon_sousuo" src="@/static/new/icon_sousuo.png"></image>
					<u-input placeholder="关键词搜索" :clearable="true" :border="false" v-model="keyword"></u-input>
					<view class="soubtn" @click="getsou">搜索</view>
				</view>
			</view>
		</u-sticky>
		<view class="fone plr">

			<view class="list">
				<view class="item" v-for="(item,index) in list" :key="index" @click="getDetail(item)">
					<image class="tubg" :src="item.img"></image>
					<view class="botview">
						<text class="biaoti txt">{{item.name}}</text>
						<text class="pjia">￥<text class="pnum">{{item.price}}</text></text>
					</view>
				</view>
				<view class="nodata" v-if="list == ''">
					<u-empty text="暂无数据" mode="list" ></u-empty>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				titleStyle:{
					fontWeight: 'bold',
					fontSize: '36rpx',
					color: '#111111',
				},
				value:'',
				title:'',
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",
				keyword:''
			}
		},
		onLoad(option) {
			this.title = option.name
			this.id = option.id
			this.getList()
		},
		onShow() {
		},
		onReachBottom: function () {
			this.loadmore();
		},
		methods: {
			async getList(){//列表数据
				let res = await this.$u.api.contractlist({
					limit:this.limit,
				  	page:this.page,
					name:this.keyword,
					class_id:this.id
				});
				// console.log(res)
				this.last_page = res.list.last_page;
				let list = res.list.list;
				this.list = this.page == 1 ? list : [...this.list, ...list];	
				if(this.page >= this.last_page){
				  this.status = 'nomore';
				}
				
			},
			loadmore() {
				let page = this.page;
				if (this.status == 'loadmore') {
					this.page++;
					this.getList();
				}
			},
			getDetail(item){
				this.navrouter("/pages/StudPage/Detail?id="+item.id);
			},
			getsou(){
				this.getClear()
			},
			
			getClear(){
				this.list = []
				this.page = 1,
				this.status= "loadmore"
				this.getList()
			}
		}
	}
</script>
<style scoped lang="scss">
	.content {
		min-height: 100vh;
		background-color: #f5f5f5;

		.souview{
			background-color: #fff;
			padding: 20rpx 30rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			
			.souitem{
				height: 78rpx;
				background: #F5F5F5;
				border-radius: 39rpx;
				display: flex;
				align-items: center;
				flex-direction: row;
				padding: 0 23rpx;
				width: 100%;
				.icon_sousuo{
					width: 24rpx;
					height: 24rpx;
					margin-right: 15rpx;
				}
				.soubtn{
					margin-left: 20rpx;
					width: 100rpx;
					height: 50rpx;
					background: #3E65E5;
					border-radius: 25rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					font-family: PingFang SC;
					font-weight: 500;
					font-size: 24rpx;
					color: #FFFFFF;
				}
			}
		}
		.fone{
			margin-top: 40rpx;
			.flist{
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
				.fitem{
					width: 25%;
					display: flex;
					flex-direction:column;
					align-items: center;
					justify-content: center;
					margin-bottom: 44rpx;
					text{
						display: inline-block;
						margin-top: 13rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
					}
					.ficon{
						width: 80rpx;
						height: 80rpx;
					}
				}
			}
			.shenhe{
				height: 60rpx;
				background: #F3F6F9;
				border-radius: 10px;
				padding: 0 30rpx;
				display: flex;
				flex-direction: row;
				align-items: center;
				.shenitem{
					width: 33.33%;
					display: flex;
					flex-direction: row;
					align-items: center;
					border-right: 1rpx solid rgba(62,101,229,0.3);
					justify-content: center;
					.shenone{
						margin-right: 3rpx;
						width: 33rpx;
						height: 33rpx;
					}
					.shentit{
						font-family: PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #3C66DE;

					}
				}
				.shenitem:last-child{
					border-right: none;
				}
			}

			.leiview{
				width: 100%;
				.leiscview{
					white-space: nowrap;
					// overflow-x: auto;
					.leiitem{
						display: inline-block;
						padding: 20rpx 40rpx;
						background: #EEEEEE;
						border-radius: 16rpx;
						font-family: PingFang SC;
						font-weight: 500;
						font-size: 24rpx;
						color: #666666;
						margin-right: 20rpx;
					}
					.lactive{
						background: #3E65E5;
						color: #fff;

					}
				}
				
			}
		}
		.list{
			display: flex;
			flex-direction: row;
			flex-wrap: wrap;
			margin-top: 30rpx;

			.item{
				width: 48.5%;
				display: flex;
				flex-direction: column;
				margin-bottom: 20rpx;
				background-color: #fff;
				border-radius: 16rpx;
				// border: 1rpx solid #eee;
				// box-shadow: 0px 3rpx 9rpx 0px rgba(109,109,109,0.1);
				
				.tubg{
					width: 100%;
					height: 330rpx;
					margin-bottom: 20rpx;
				}
				.botview{
					display: flex;
					flex-direction: column;
					padding: 20rpx ;
				}
				.biaoti{
					display: inline-block;
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 26rpx;
					color: #333333;
				}
				.pjia{
					font-family: PingFang SC;
					font-weight: bold;
					font-size: 26rpx;
					color: #E53E3E;
					display: block;
					margin-top: 20rpx;
					.pnum{
						font-size: 36rpx;
					}
				}
			}
			.item:nth-child(even){
				margin-left: auto;
			}
		}
		.txt {
			white-space: nowrap;
			overflow: hidden;
			text-overflow: ellipsis;
		}
		.plr{
			padding: 0 30rpx;
		}
		.ftit{
			display: block;
			margin-bottom: 30rpx;
			font-family: PingFang SC;
			font-weight: bold;
			font-size: 36rpx;
			color: #111111;
		}



	}
</style>